package com.petmagics.learnanimation;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;

/**
 * 透明动画
 */
public class AlphaAnimationFm extends Fragment {

    public AlphaAnimationFm() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_alpha_animation, container, false);

        rootView.findViewById(R.id.btnBack).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                getFragmentManager().popBackStack();
            }
        });

        rootView.findViewById(R.id.btnAlphaMe).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //代码方式
//                    AlphaAnimation aa = new AlphaAnimation(0,1);
//                    aa.setDuration(1000);
//                    view.startAnimation(aa);
                //xml方式
                view.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.aa));
            }
        });

        return rootView;
    }
}
